
package com.zwh.develop;


import com.zwh.develop.support.CgbCodeGenerator;
import com.zwh.develop.support.SysCodeGenerator;

/**
 * 代码生成器
 *
 * @author Chill
 */
public class CodeGenerator {

	/**
	 * 代码生成的模块名
	 */
	public static String CODE_NAME = "zwh";
	/**
	 * 代码所在服务名
	 */
	public static String SERVICE_NAME = "com-zwh";
	/**
	 * 代码生成的包名
	 */
	public static String PACKAGE_NAME = "com.zwh";
	/**
	 * 前端代码生成所属系统
	 */
	public static String SYSTEM_NAME = "saber";
	/**
	 * 前端代码生成地址
	 */
	public static String PACKAGE_WEB_DIR = "D:/Workspaces/product/Saber";
	/**
	 * 需要去掉的表前缀
	 */
	public static String[] TABLE_PREFIX = {"T_"};
	/**
	 * 需要生成的表名(两者只能取其一)
	 */
	public static String[] INCLUDE_TABLES = {
		"t_mybatis_user"
	};
	/**
	 * 需要排除的表名(两者只能取其一)
	 */
	public static String[] EXCLUDE_TABLES = {};
	/**
	 * 是否包含基础业务字段
	 */
	public static Boolean HAS_SUPER_ENTITY = Boolean.FALSE;
	/**
	 * 基础业务字段
	 */
	public static String[] SUPER_ENTITY_COLUMNS = {};


	/**
	 * RUN THIS
	 */
	public static void run() {
		CgbCodeGenerator generator = new CgbCodeGenerator();
		generator.setSystemName(SYSTEM_NAME);
		generator.setPackageName(PACKAGE_NAME);
		generator.setTablePrefix(TABLE_PREFIX);
		generator.setIncludeTables(INCLUDE_TABLES);
		generator.setExcludeTables(EXCLUDE_TABLES);
		generator.run();
	}

	public static void main(String[] args) {
		run();
	}

//
//	public static void main(String[] args) {
//		Collection<Code> codes = codeService.listByIds(Func.toLongList(ids));
//		codes.forEach(code -> {
//			SysCodeGenerator generator = new sysCodeGenerator();
//			// 设置数据源
//			Datasource datasource = datasourceService.getById(code.getDatasourceId());
//			generator.setDriverName(datasource.getDriverClass());
//			generator.setUrl(datasource.getUrl());
//			generator.setUsername(datasource.getUsername());
//			generator.setPassword(datasource.getPassword());
//			// 设置基础配置
//			generator.setSystemName(system);
//			generator.setCodeName(code.getCodeName());
//			generator.setServiceName(code.getServiceName());
//			generator.setPackageName(code.getPackageName());
//			generator.setPackageDir(code.getApiPath());
//			generator.setPackageWebDir(code.getWebPath());
//			generator.setTablePrefix(Func.toStrArray(code.getTablePrefix()));
//			generator.setIncludeTables(Func.toStrArray(code.getTableName()));
//			// 设置是否继承基础业务字段
//			generator.setHasSuperEntity(code.getBaseMode() == 2);
//			// 设置是否开启包装器模式
//			generator.setHasWrapper(code.getWrapMode() == 2);
//			generator.run();
//		});
//	}

}
